#ifndef CHARACTERCLASS_H
#define CHARACTERCLASS_H

#include "dtwenty_global.h"
#include "skill.h"
#include "specialability.h"
#include "dtwentyitem.h"


#include <QPointer>
#include <QMap>


class DTWENTYSHARED_EXPORT CharacterClass : public DTwentyItem
{
    Q_OBJECT

    Q_PROPERTY(int hitDie READ hitDie WRITE setHitDie)
    Q_PROPERTY(int skillPoints READ skillPoints WRITE setSkillPoints)

    class Data : public QSharedData
    {
    public:
        Data() {}
        Data(const Data& other) : QSharedData(other)
        {
            hitDie = other.hitDie;
            skillPoints = other.skillPoints;
        }

        QVariant hitDie;
        QVariant skillPoints;

    };


public:

    Q_INVOKABLE CharacterClass(const QString& name = QString(), QObject* parent = 0);
    CharacterClass(const CharacterClass& other);

    int hitDie() const;
    void setHitDie(int hitDie);

    int skillPoints() const;
    void setSkillPoints(int skillPoints);

    QList<Skill*> classSkills() const;
    void addClassSkill(const Skill& skill);
    void removeClassSkill(int at);

    QList<SpecialAbility*> specialAbilities(int level) const;
    void addSpecialAbility(int level, const SpecialAbility& special);
    void specialAbility(int level, int at);


private:

    SkillContainer* classSkillsContainer();
    SpecialAbilityContainer* specialAbilityContainer(int level);

    QExplicitlySharedDataPointer<Data> d;


};


Q_DECLARE_METATYPE(CharacterClass)


typedef DTwentyItemContainer<CharacterClass> CharacterClassContainer;
Q_DECLARE_METATYPE(CharacterClassContainer)

#endif // CHARACTERCLASS_H
